<?php

namespace app\wechat\controller;


use app\common\controller\AdminController;
use think\App;
use think\facade\Env;
use EasyWeChat\Factory;
use app\wechat\domain\Applet;
use app\common\service\JwtService as Jwt;

class Api
{

    
    public function getApplet()
    {
        $config=[
			"app_id"=>"wxfa2688fbb131b861",
			"secret"=>"cb868a27eabcaa4566e1b80cb87cdb0b",
			'response_type' => 'array',
        ];
        // dump(Factory);
        $Factorys=new Factory();
		$app = Factory::miniProgram($config);
		// $app = $Factorys->miniProgram($config);
		dump($app);

		// return $app;
    }
    public function getToken(){
        $applet =new Applet();
        $token=$applet->getToken();
        if ($token) {
            result(200,"获取成功",$token);
            
        } else {
            result(400,"获取失败",[]);

        }
        
    }
     public function getOpenId(){
        $applet =new Applet();
        $token=$applet->getOpenId();
        if ($token) {
            result(200,"获取成功",$token);
        } else {

        }
    }
    public function token(){
		$JWT=new Jwt();
		$token=$JWT->getToken(12);
		dump($token);
	}
}
